package org.blaznyoght.subtitles.ui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JMenuItem;

public class PlayerActionListener implements ActionListener {
	private SwingApplication application;

	public PlayerActionListener(SwingApplication swingApplication) {
		setApplication(swingApplication);
	}

	/**
	 * @return the application
	 */
	public SwingApplication getApplication() {
		return application;
	}

	/**
	 * @param application the application to set
	 */
	public void setApplication(SwingApplication application) {
		this.application = application;
	}

	private void stop() {
		application.stop();
	}

	private void playPause() {
		application.playPause();
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		Object source = e.getSource();
		if (source instanceof JMenuItem) {
			JMenuItem clickedItem = (JMenuItem) source;
			if (clickedItem.getText().equals("play/pause")) {
				playPause();
			}
			else if (clickedItem.getText().equals("stop")) {
				stop();
			}
		}
	}

	
}
